package cn.swust.designpatternlearningplatform.dao;

import cn.swust.designpatternlearningplatform.dao.sql.TopicKnowledgePointDaoSql;
import cn.swust.designpatternlearningplatform.domain.entity.KnowledgePoint;
import cn.swust.designpatternlearningplatform.domain.entity.TopicKnowledgeCorrelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;
import java.util.Set;

@Mapper
public interface TopicKnowledgePointDao {
    /**
     * 返回该知识点下的子知识点
     *
     * @param parentId
     * @return java.util.List<cn.swust.designpatternlearningplatform.domain.entity.KnowledgePoint>
     * @author Tang
     * @date 2023/4/16 2:16
     **/
    @SelectProvider(value = TopicKnowledgePointDaoSql.class, method = "selectKnowledgePointById")
    List<KnowledgePoint> selectKnowledgePointSonId(@Param("id") Integer parentId);

    /**
     * 根据id查知识点信息
     *
     * @param id
     * @return cn.swust.designpatternlearningplatform.domain.entity.KnowledgePoint
     * @author Tang
     * @date 2023/4/16 2:34
     **/
    @Select("SELECT " +
            "point_id, parent_id, point_content " +
            "FROM knowledge_point " +
            "WHERE point_id = #{id}")
    KnowledgePoint selectKnowledgePointById(@Param("id") Integer id);

    /**
     * 获取知识点的总数目
     *
     * @return java.lang.Integer
     * @author Tang
     * @date 2023/5/17 11:00
     **/
    @Select("SELECT COUNT(*) FROM knowledge_point")
    Integer selectKnowledgePointNum();

    @SelectProvider(type = TopicKnowledgePointDaoSql.class, method = "selectPointIdByContent")
    Integer selectPointIdByContent(String topicKnowledge);

    List<KnowledgePoint> selectByPointIds(@Param("pointIds") Set<Integer> pointIds);

    /**
     * 根据topicId列表，批量查询知识点信息
     *
     * @param topicIds
     * @return java.util.List<cn.swust.designpatternlearningplatform.domain.entity.KnowledgePoint>
     * @author Tang
     * @date 2023/7/17 21:15
     **/
    List<TopicKnowledgeCorrelation> selectByTopicIds(@Param("topicIds") List<Integer> topicIds);
}
